package com.wanmait.deliverymangementsystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.deliverymangementsystem.mapper.HistoryOrdersMapper;
import com.wanmait.deliverymangementsystem.pojo.HistoryOrders;
import com.wanmait.deliverymangementsystem.service.HistoOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HistoryOrderServiceImpl implements HistoOrderService {
    @Resource
    private HistoryOrdersMapper historyOrdersMapper;

    @Override
    public PageInfo<HistoryOrders> findAllByUserIDandPageNo(Integer id, Integer pageNo) {
        PageHelper.startPage(pageNo, 5);

        List<HistoryOrders> historyOrders = historyOrdersMapper.findAllByUserID(id);
        PageInfo<HistoryOrders> historyOrdersPageInfo = new PageInfo<>(historyOrders, 3);
        return historyOrdersPageInfo;
    }

    @Override
    public void insert(HistoryOrders historyOrders) {
        historyOrdersMapper.insert(historyOrders);
    }

    @Override
    public void completeReviewByTaskId(Integer ID) {
        historyOrdersMapper.updateStatusByTaskID(ID);
    }

    @Override
    public void deleteUserByID(Integer id) {
        historyOrdersMapper.deleteUserByID(id);
    }

    @Override
    public void deleteRunnerByID(Integer id) {
        historyOrdersMapper.deleteRunnerByID(id);
    }

    @Override
    public void deleteAdminByID(Integer id) {
        historyOrdersMapper.deleteAdminByID(id);
    }

    @Override
    public void deleteUserByTaskID(Integer id) {
        historyOrdersMapper.deleteUserByTasksID(id);
    }

    @Override
    public void deleteAdminByTaskID(Integer id) {
        historyOrdersMapper.deleteAdminByTasksID(id);
    }

    @Override
    public void deleteRunnerByTaskID(Integer id) {
        historyOrdersMapper.deleteUserByTasksID(id);
    }


}
